package com.xmzgxcl.java202108.controller;

import com.xmzgxcl.java202108.util.CheckCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author venky-ming
 * @Date 2021/12/14 12:01
 */
@Controller
@RequestMapping("/check")
public class CheckCodeController {
    @RequestMapping("/code")
    public void code(HttpServletRequest request, HttpServletResponse response) {
        response.setContentType("image/jpeg");
        response.setHeader("Cache-Control","no-cache");
        response.setHeader("Pragma", "no-cache");
        response.setDateHeader("Expire", 0);
        try {
            CheckCodeUtil.getInstance().getCheckCode(request,response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
